<?php

namespace addon\lian\api\controller;

use addon\lian\model\LianLevel;
use app\api\controller\BaseApi;
use think\Response;


/**
 * 链动2+1等级
 */
class Level extends BaseApi
{

    /**
     * 链动2+1等级列表
     */
    public function lists()
    {
        $token = $this->checkToken();
        if ($token[ 'code' ] < 0) return $this->response($token);

        $condition = [
            [ 'status', '=', 1 ],
            [ 'site_id', '=', $this->site_id ],
            [ 'is_default', '=', 0 ]
        ];
        $model = new LianLevel();
        $info = $model->getLevelList($condition, '*', 'level_num asc');

        return $this->response($info);
    }


    /**
     * 链动会员等级详情
     * @param int $id
     */
    public function info(int $id)
    {
        $token = $this->checkToken();
        if ($token[ 'code' ] < 0) return $this->response($token);

        $model = new LianLevel();
        $info = $model->getLevelInfo([ 'level_id' => $id, 'site_id' => $this->site_id ]);

        return $this->response($info);
    }

}